package thinkingJava.chapter11;

import java.util.ArrayList;

public class Gerbil {
	private int gerbilNumber;

	public Gerbil(int gerbilNumber) {
		this.gerbilNumber = gerbilNumber;
	}

	public void hop() {
		System.out.println(gerbilNumber);
	}
	public static void main(String[] args) {
		ArrayList<Gerbil> list = new ArrayList<Gerbil>();
		for (int i = 0; i < 5; i ++) {
			list.add(new Gerbil(i));
		}
		for (int i = 0; i < list.size() ; i++) {
			list.get(i).hop();
		}
		System.out.println("---------------");
		for (Gerbil g : list) {
			g.hop();
		}
	}
}
